/**
 * 消费适配的例子 sum
 */
fn iterator_sum() {
    let v1 = vec![1, 2, 3];
    let v1_iter = v1.iter();
    let total: i32 = v1_iter.sum();
    println!("Sum: {}", total);
}

fn main(){
    iterator_sum();
    let v1: Vec<i32> = vec![1, 2, 3];
    println!("向量v1的值={:?}",v1 );
    let i1=v1.iter();
    //迭代器适配器例子-创造新的迭代器
    let i2=v1.iter().map(|x| x + 1);
    println!("逐个打印向量V1的值,但是用了+1的迭代器----------");
    for i in i2 {
        println!("{}", i);
    }
    println!("逐个打印向量V1的值----------");
    for i in i1 {
        println!("{}", i);
    }
}